********************************************
* Regression Analysis
********************************************

set scheme s1color

global con female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents

* Read the Master data file
use "$cleaned_dir/language_master.dta", clear

gen newstd=99
replace newstd=4 if new_std==4
replace newstd=5 if new_std==5
replace newstd=6 if new_std==6

gen int std4=1 if std==4
replace std4=2 if std==5 


tab newstd, gen(haha)


label variable sum_part "Learning Camp Participants"
label variable sum_nonpart "Learning Camp Non-participants"


*************************************************************************
* Table A2 Descriptive Analysis and Balance Checks
*************************************************************************

* Table A2 Panels A-E variables
global EDCC_sum female bs_bothparents bs_chewa bs_ever_repeat bs_absent	bs_num_txtbk bs_ownstationarya bs_ownstationaryb bs_ownstationaryc bs_studywkdays bs_goodhealth bs_parent_b_dum bs_parent_d_dum bs_parent_el_score_z bs_edumotive_score_z bs_subjectexp_af_z bs_subjectexp_gl_z  bs_misshw_dum bs_classenviron4_dum bs_classenviron5_dum bs_teacherpercep_score_z bs_listen_chiz bs_listen_engz chichewa_good eng_good bs_cogz bs_comz bs_subjectperfa_dum bs_subjectperfb_dum bs_subjectperfc_dum bs_subjectperfd_dum bs_subjectperfe_dum bs_subjectperff_dum 

preserve


order $EDCC_sum 
keep $EDCC_sum

outreg2 using "$table_dir/EDCC_TableA2_Col_12.xls", excel replace label sum(log) keep($EDCC_sum) eqkeep(N mean sd) 

restore

preserve

gen che_eng=0 if summer_part_chewa==1
replace che_eng=1 if summer_part_eng==1
	
local toto "replace"
	
	* Columns (3) and (4)
	foreach i in $EDCC_sum {
	reg `i' summer_class_chewa summer_class_eng , r cluster(school_code)
		test summer_class_chewa=summer_class_eng=0
		local F=r(p)
		outreg2 using "$table_dir/EDCC_TableA2_Col_34.xls", excel `toto' label depvar sideway keep(summer_class_chewa summer_class_eng) nocons adds(P-value: Chewa=Eng=Ctrl, `F')	
		local toto "append"
		}

	* Columns (5)-(8)
local toto "replace"
	foreach i in $EDCC_sum {
	reg `i' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng, r cluster(school_code)
		test summer_part_chewa=summer_part_eng=summer_nonpart_chewa=summer_nonpart_eng=0
		local F=r(p)
		outreg2 using "$table_dir/EDCC_TableA2_Col_58.xls", excel `toto' label depvar sideway keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(Chewa=Eng=Ctrl Prob<F, `F')	
		local toto "append"
		}

	* Columns (9)
local toto "replace"
foreach i in $EDCC_sum {

		ttest `i', by(che_eng) unequal
		matrix ttest1=(r(mu_2)-r(mu_1), r(se), r(p))
		matrix ttest1=ttest1'
		matrix colnames ttest1= `i'_che_eng
		matrix rownames ttest1= mean_diff se pval
		mat2txt, matrix(ttest1) sav("$table_dir/EDCC_TableA2_Col_9.xls") `toto'
		local toto "append"
	}

restore

	
******************************************************************************************
****** Table A3: Attrition
******************************************************************************************

////////////////////////////////////////////////////////////////////////////////
foreach i in fs t1e  f2 t2e {
	gen `i'_attrition=`i'_merge!=3
	}

replace t1e_attrition=1 if fs_ssz==.
replace t2e_attrition=1 if t2e_mark_socialz==.

label variable fs_attrition "Term 1 follow-up survey attrition"
label variable t1e_attrition "Term 1 final exam attrition"
label variable f2_attrition "Term 2 follow-up survey attrition"
label variable t2e_attrition "Term 2 final exam attrition"

local yoyo "replace"
foreach i in  fs t1e  f2 t2e {
     forval k=1/2 {
	 local l: word `k' of " " "$con"
	 local q: word `k' of "No" "Yes"
    
	areg `i'_attrition sum_part sum_nonpart i.newstd `l', absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `i'_attrition if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	

	outreg2 using "$table_dir/EDCC_TableA3_Panel_A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: P=Non-P, `F1', BS P-value: P=Non-P, `H1', Mean of Dep. Var, `F2', WCSE_summer_part, `G1' , WCSE_nonpart, `G2')	addtext(Control, `q')	

	areg `i'_attrition summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd `l', absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize `i'_attrition if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	local F2=r(p)
	test summer_part_eng=summer_nonpart_eng
	local F3=r(p)
	test summer_nonpart_chewa=summer_nonpart_eng
	local F4=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_TableA3_Panel_B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: C=E, `F1', BS P-value: C=E, `H1', Mean of Dep. Var, `F5', WCSE_summer_Chewa, `G1' , WCSE_summer_Eng, `G2', WCSE_nosummer_Chewa, `G3', WCSE_nosummer_Eng, `G4') addtext(Control, `q')	
	
	local yoyo "append"
	
	}
	
 }	

 
******************************************************************************************
****** Table 1: summer school outcomes by language of instruction Columns 5-6 (Attendance)
******************************************************************************************

* regression on number of attendance
* Table 1 Column (5) 
eststo: reg num_attend summer_part_chewa i.zone i.newstd if summer_school==1, r cluster(school_code)
boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
local G1=r(p)
sum num_attend if e(sample)==1 & summer_part_chewa==0
local F1=r(mean)
outreg2 using "$table_dir/EDCC_Table1_Col56.xls", excel replace label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', BT_part_chewa, `G1')

* Table 1 Column (6) 
eststo: reg num_attend summer_part_chewa i.zone i.newstd $con if summer_school==1, r cluster(school_code)
boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
local G1=r(p)
sum num_attend if e(sample)==1 & summer_part_chewa==0
local F1=r(mean)
outreg2 using "$table_dir/EDCC_Table1_Col56.xls", excel append label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', BT_part_chewa, `G1')


******************************************************************************************
****** Table A11: summer school outcomes by language of instruction by grade Columns 5-6 (Attendance)
******************************************************************************************

local momo "replace"

* Calculate P-value for the equality test: STD4=STD5
reg num_attend summer_part_chewa  i.zone $con haha1-haha3 if summer_school == 1 & std4==1
est store regattend1

reg num_attend summer_part_chewa i.zone $con haha1-haha3 if summer_school == 1 & std4==2
est store regattend2

suest regattend1 regattend2, cluster(school_code)
test [regattend1_mean]summer_part_chewa = [regattend2_mean]summer_part_chewa
local H1=r(p)

estimates clear

forval k=1/2 {

eststo: reg num_attend summer_part_chewa i.zone $con i.newstd  if summer_school==1 & std4==`k', r cluster(school_code)
boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
local G1=r(p)
summ num_attend if e(sample)==1 & summer_part_chewa==0
local F1=r(mean)
outreg2 using "$table_dir/EDCC_TableA11_Col56.xls", excel `momo' label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', BT_part_chewa, `G1', "std4", `k', P-value: STD4=STD5, `H1')
local momo "append"
	}



******************************************************************************************
****** Table A4: Students' learning camp exit survey
******************************************************************************************

foreach i in q105 q108 q109 {
	gen es_`i'_assigned=.
	replace es_`i'_assigned=1 if es_`i'_chi==1 & summer_language==1
	replace es_`i'_assigned=1 if es_`i'_eng==1 & summer_language==2
	replace es_`i'_assigned=0 if summer_school==1 & es_`i'_assigned==.
	}

label variable es_q105_assigned "Assigned language spoken by teacher"
label variable es_q108_assigned "Assigned language used to ask questions"
label variable es_q109_assigned "Assigned language used to discuss with peers"

local toto "replace"

foreach i of varlist es_q105_assigned es_q108_assigned es_q109_assigned   {

		forval k=1/2 {
		
		local l: word `k' of " " "$con"
		local q: word `k' of "No" "Yes"
		
		quietly reg `i' summer_part_chewa i.zone i.newstd $con if summer_school == 1, r cluster(school_code)
		gen temp=e(sample)
		
		reg `i' summer_part_chewa i.zone i.newstd `l' if summer_school == 1 & temp==1, r cluster(school_code)
		boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p)
		sum `i' if e(sample)==1 & summer_part_chewa==0
		local F1=r(mean)	
		outreg2 using "$table_dir/EDCC_TableA4.xls", excel `toto' label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', WCSE_Chewa, `G1')	addtext(Control, `q')	
		drop temp 
		
		local toto "append"
	}
   	
}

	
		

	
******************************************************************************************
****** Figure 2 Panel A: Distribution of Test Scores, Learning Camp Weekly Test
******************************************************************************************

* creating pooled scores
keep social_1z social_2z social_3z social_4z social_Finalz math_1z math_2z math_3z math_4z math_Finalz $con std5 newstd summer_school school_code std summer_part_chewa id zone num_attend bs_*  $hetero
ren social_*z social_*
ren math_*z math_*
ren *_Final *_5
reshape long social_ math_, i(id) j(week)
ren math_ mathz
ren social_ socialz
tab newstd, gen(haha)

** Figure 2 Panel A
forval i=1/2 {

local j: word `i' of "socialz" "mathz" 
local k: word `i' of "Social Studies" "Mathematics" 
local w: word `i' of "Social" "Math" 


twoway (kdensity `j' if summer_part_chewa==1 & summer_school==1, bw(0.5) clcolor(black) clpattern(shortdash)) ///
	(kdensity `j' if summer_part_chewa==0 & summer_school==1 , bw(0.5)  clcolor(black) clpattern(solid)), /// 
	ytitle("Learning Camp `k' Scores", margin(medsmall)) ///
	xtitle("", margin(small)) legend(order(1 "Chichewa Group" 2 "English Group")) xlabel(#9) xmtick(##2) ///
	graphregion(fcolor(white)) plotregion(fcolor(white))
	graph save Graph "$figure_dir\EDCC_Fig2_Panel_A_`w'.gph", replace
	graph export "$figure_dir\EDCC_Fig2_Panel_A_`w'.tif", replace

}


 
******************************************************************************************
****** Table 1: summer school outcomes by language of instruction Columns 1-4 
******************************************************************************************

label variable socialz "Social studies weekly test score"
label variable mathz "Mathematics weekly test score"

* MHT-adjusted p-values
preserve
keep if summer_school==1
* Table 1 w/o all controls 
wyoung, cmd("areg socialz summer_part_chewa $con i.newstd i.week , r a(zone)" "areg mathz summer_part_chewa $con i.newstd i.week  , r a(zone)")  familyp(summer_part_chewa) bootstraps(10000) seed(98243532) cluster(school_code)
matrix table1=r(table)
scalar social_table1 = table1[1,4]  
display "social_table1: " social_table1
scalar math_table1 = table1[2,4]  
display "math table1: " math_table1


* Table 1 w/ all controls 
wyoung, cmd("areg socialz summer_part_chewa $con i.newstd i.week , r a(zone)" "areg mathz summer_part_chewa $con i.newstd i.week , r a(zone)")  familyp(summer_part_chewa) bootstraps(10000) seed(98243532) cluster(school_code)
matrix table2=r(table)
scalar social_table2 = table2[1,4]  
display "social_table1: " social_table2
scalar math_table2 = table2[2,4]  
display "math table2: " math_table2


local toto "replace"

forval i=1/2 {

	local j: word `i' of "socialz" "mathz"  
	local w: word `i' of "social" "math"  
	

	forval k=1/2 {
		
		local l: word `k' of " " "$con"
		local q: word `k' of "No" "Yes"
		  
		reg `j' summer_part_chewa i.week i.zone i.newstd `l' if summer_school == 1, r cluster(school_code)
		boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p)
		sum `j' if e(sample)==1 & summer_part_chewa==0
		local F1=r(mean)	
		outreg2 using "$table_dir/EDCC_Table1_Col14.xls", excel `toto' label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', WCSE_Chewa, `G1', MHT p-val:, `w'_table`k' )	addtext(Control, `q')	
		
		local toto "append"
  }
  
}


******************************************************************************************
****** Table A11: summer school outcomes by language of instruction by Grade: Columns 1-4 
******************************************************************************************
  
gen int std4=1 if std==4
replace std4=2 if std==5   
  
local toto "replace"

forval i=1/2 {

local j: word `i' of "socialz" "mathz"  
local w: word `i' of "social" "math"  
	
est clear
* AT8 mean difference test by grade
qui reg `j' summer_part_chewa i.week i.zone $con haha1-haha3 if summer_school == 1 & std4==1
est store r_`j'1
qui reg `j' summer_part_chewa  i.week i.zone $con haha1-haha3  if summer_school == 1 & std4==2
est store r_`j'2

qui suest r_`j'1 r_`j'2, cluster(school_code)
test [r_`j'1_mean]summer_part_chewa = [r_`j'2_mean]summer_part_chewa
local H1=r(p)

forval k=1/2 {
  local q: word `k' of "STD4" "STD5"

	reg `j' summer_part_chewa $con i.newstd i.week i.zone if summer_school == 1 & std4==`k', r cluster(school_code)
	boottest summer_part_chewa, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p)
	sum `j' if e(sample)==1 & summer_part_chewa==0
	local F1=r(mean)
	outreg2 using "$table_dir/EDCC_TableA11_Col14.xls", excel `toto' label depvar keep(summer_part_chewa) nocons adds(Mean of Dep. Var, `F1', WCSE_Chewa, `G1', P-value: STD4=STD5, `H1')	addtext(Control, "Yes",  Grade, "`q'")
	local toto "append"
	}
	
}
  
restore



******************************************************************************************
*** TABLE 2: Short-term Learning Camp Impacts
******************************************************************************************
use "$cleaned_dir/language_master.dta", clear

gen newstd=99
replace newstd=4 if new_std==4
replace newstd=5 if new_std==5
replace newstd=6 if new_std==6
gen int std4=1 if std==4
replace std4=2 if std==5 
tab newstd, gen(haha)

**** Columns 1-4, 7-10

*** Preparation for RWOLF
gen w1=sum_part
gen w2=sum_nonpart

global ycon1 haha1 haha2 haha3
global ycon2 female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents haha1 haha2 haha3

* MHT-robust SEs
forval b=1/2 {

local e: word `b' of `" $ycon1" " $ycon1" " $ycon1" " $ycon1"' `" $ycon2" " $ycon2" " $ycon2" " $ycon2"' 
local g: word `b' of `"w1 w2"' `"w1 w2"' 

wyoung fs_svysocialz fs_ssz fs_svymathz fs_mathz , cmd(areg OUTCOMEVAR "`g'" CONTROLVARS, r a(zone)) familyp("`g'") controls("`e'") bootstraps(10000) seed(98243532) cluster(school_code)
	
matrix table`b'=r(table)
scalar svysocialz_par`b' = table`b'[1,4]  
scalar ssz_par`b' = table`b'[2,4]  
scalar svymathz_par`b' = table`b'[3,4]  
scalar mathz_par`b' = table`b'[4,4]  

display "social_fs_par`b': " svysocialz_par`b'
display "social_t1_par`b': " ssz_par`b'
display "math_fs_par`b': " svymathz_par`b'
display "math_t1_par`b': " mathz_par`b'

scalar svysocialz_non`b' = table`b'[5,4]  
scalar ssz_non`b' = table`b'[6,4]  
scalar svymathz_non`b' = table`b'[7,4]  
scalar mathz_non`b' = table`b'[8,4]  

display "social_fs_non`b': " svysocialz_non`b'
display "social_t1_non`b': " ssz_non`b'
display "math_fs_non`b': " svymathz_non`b'
display "math_t1_non`b': " mathz_non`b'

}


local yoyo "replace"
local toto "replace"
local momo "replace"

forval i=1/4 {




local j: word `i' of "svysocialz" "ssz" "svymathz" "mathz"   


  forval k=1/2 {
  local l: word `k' of " " "$con"
  local q: word `k' of "No" "Yes"



  	areg fs_`j' sum_part sum_nonpart `l' i.newstd, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local G1=r(p_1)
	local G2=r(p_2)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table2.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: P=Non-P, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2', MHT PAR p-val:, `j'_par`k', MHT NON p-val:, `j'_non`k')	
	
	local yoyo "append"
	
  }


*** Heterogeneity analysis 
******************************************************************************************
*** TABLE A12: Short-term Learning Camp Impacts by Grade
******************************************************************************************

* mean difference test by grade
			qui reg fs_`j' sum_part sum_nonpart $con haha1-haha3 i.zone if std4==1
			est store r_`j'4
			qui reg fs_`j' sum_part sum_nonpart $con haha1-haha3 i.zone if std4==2
			est store r_`j'5

			qui suest r_`j'4 r_`j'5, cluster(school_code)
			test [r_`j'4_mean]sum_part = [r_`j'5_mean]sum_part
			local H1=r(p)

			
			forval k=1/2 {
			local q: word `k' of "STD4" "STD5"

			areg fs_`j' sum_part sum_nonpart i.newstd $con if std4==`k', absorb(zone) r cluster(school_code)
			boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
			local G1=r(p_1)
			local G2=r(p_2)
			summarize fs_`j' if lang3==0 & e(sample)==1
			local F2=r(mean)
			test sum_part=sum_nonpart
			local F1=r(p)
			outreg2 using "$table_dir/EDCC_TableA12A.xls", excel `momo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value PAR: STD4=STD5, `H1', Mean of Dep. Var, `F2', BT_part, `G1' , BT_nonpart, `G2')	addtext(Control, "Yes", Grade, "`q'")
			local momo "append"


			}
		
	
}


 


***************************************************************************************
* Table 2 Pooled, Standardized Scores (FS and Term 1 Finals) and Figure 2 Panel B
***************************************************************************************
preserve

keep id fs_svysocialz fs_svymathz summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng bs_mathz bs_ssbkz school_code zone std female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents std5 new_std lang3  fs_ssz fs_mathz  fs_totalz $hetero


ren fs_svysocialz ssz
ren fs_svymathz mathz



* Follow-up survey
gen type=0
save "$cleaned_dir/T2POOL.dta", replace

* Term 1 exam
use "$cleaned_dir/language_master.dta", clear

keep id fs_ssz fs_mathz summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng bs_mathz bs_ssbkz school_code zone std female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents std5 new_std lang3 bs_comz bs_cogz fs_cogz fs_comz fs_svymathz fs_svysocialz fs_ssz fs_mathz fs_totalz $hetero chichewa_good eng_good bs_listen_chiz bs_listen_engz bs_goodhealth bs_edumotive_score_z bs_subjectexp_af_z bs_subjectexp_gl_z bs_absent bs_studywkdays bs_misshw_dum bs_classenviron4_dum bs_classenviron5_dum bs_teacherpercep_score_z bs_parent_b_dum bs_parent_b_dum bs_parent_d_dum bs_parent_el_score_z bs_ownstationarya bs_ownstationaryb bs_ownstationaryc bs_subjectperfa_dum bs_subjectperfb_dum bs_subjectperfc_dum bs_subjectperfd_dum bs_subjectperfe_dum bs_subjectperff_dum

ren fs_ssz ssz
ren fs_mathz mathz
* Term 1 exam
gen type=1

append using "$cleaned_dir/T2POOL.dta"

gen newstd=99
replace newstd=4 if new_std==4
replace newstd=5 if new_std==5
replace newstd=6 if new_std==6

tab newstd, gen(haha)

gen int std4=1 if std==4
replace std4=2 if std==5 

gen sum_part=(summer_part_chewa==1 | summer_part_eng==1)
gen sum_nonpart=(summer_nonpart_chewa==1 | summer_nonpart_eng==1)


** Figure 2 Panel B

twoway (kdensity ssz if summer_part_chewa==1, bw(0.5) clcolor(black) clpattern(solid)) ///
	(kdensity ssz if summer_part_eng==1, bw(0.5)  clcolor(black) clpattern(shortdash)) /// 
	(kdensity ssz if lang3==0, bw(0.5)  clcolor(black) clpattern(dash) clwidth(vvthink)), ///
	title("AY17 Term 1 Social Studies Scores", margin(medsmall)) ///
	ytitle("") ///
	xtitle("", margin(small)) legend(order(1 "Chichewa Participants" 2 "English Participants" 3 "Control")) xlabel(#9) xmtick(##2) ///
	graphregion(fcolor(white)) plotregion(fcolor(white))
	graph save Graph "$figure_dir\EDCC_Fig2_Panel_B_social.gph", replace
	graph export "$figure_dir\EDCC_Fig2_Panel_B_social.tif", replace width(2000)
	

twoway (kdensity mathz if summer_part_chewa==1, bw(0.5) clcolor(black) clpattern(solid)) ///
	(kdensity mathz if summer_part_eng==1, bw(0.5)  clcolor(black) clpattern(shortdash)) /// 
	(kdensity mathz if lang3==0, bw(0.5)  clcolor(black) clpattern(dash) clwidth(vvthink)), ///
	title("AY17 Term 1 Mathematics Scores", margin(medsmall)) ///
	ytitle("") ///
	xtitle("", margin(small)) legend(order(1 "Chichewa Participants" 2 "English Participants" 3 "Control")) xlabel(#9) xmtick(##2) ///
	graphregion(fcolor(white)) plotregion(fcolor(white))
	graph save Graph "$figure_dir\EDCC_Fig2_Panel_B_math.gph", replace
	graph export "$figure_dir\EDCC_Fig2_Panel_B_math.tif", replace width(2000)
	
	

** Table 2 Pooled Columns 5, 6, 11, and 12

gen school_code2=school_code+type*(100+school_code)


*** Preparation for RWOLF
gen w1=sum_part
gen w2=sum_nonpart

* MHT-robust SEs
forval b=1/2 {
	local e: word `b' of `"$ycon1" "$ycon1"' `"$ycon2" "$ycon2"' 

wyoung ssz mathz, cmd(areg OUTCOMEVAR w1 w2 CONTROLVARS, r a(zone)) familyp(w1 w2) controls("`e'") bootstraps(10000) seed(98243532) cluster(school_code)

matrix table`b'=r(table)
scalar ssz_par`b' = table`b'[1,4]  
scalar mathz_par`b' = table`b'[2,4]  

display "social_stacked_par`b': " ssz_par`b'
display "math_stacked_par`b': " mathz_par`b'

scalar ssz_non`b' = table`b'[3,4]  
scalar mathz_non`b' = table`b'[4,4]  

display "social_stacked_non`b': " ssz_non`b'
display "math_stacked_non`b': " mathz_non`b'
}


local toto "replace"
forval i=1/2 {

local j: word `i' of "ssz" "mathz" 


  forval k=1/2 {
  local l: word `k' of " " "$con"
  
  	areg `j' sum_part sum_nonpart `l' i.newstd type, absorb(zone) r cluster(school_code2)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code2) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table2_Stacked.xls", excel `toto' depvar keep(sum_part sum_nonpart) nocons adds(P-value: P=Non-P, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', BT_part, `G1' , BT_nonpart, `G2', MHT PAR p-val:, `j'_par`k', MHT NON p-val:, `j'_non`k')	
	local toto "append"
	
	}
	
	
* mean difference test by grade
			qui reg `j' sum_part sum_nonpart $con haha1-haha3 i.zone if std4==1
			est store r_`j'4
			qui reg `j' sum_part sum_nonpart $con haha1-haha3 i.zone if std4==2
			est store r_`j'5

			qui suest r_`j'4 r_`j'5, cluster(school_code)
			test [r_`j'4_mean]sum_part = [r_`j'5_mean]sum_part
			local H1=r(p)


forval k=1/2 {
			local q: word `k' of "STD4" "STD5"

			areg `j' sum_part sum_nonpart i.newstd $con if std4==`k', absorb(zone) r cluster(school_code)
			boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
			local G1=r(p_1)
			local G2=r(p_2)
			summarize `j' if lang3==0 & e(sample)==1
			local F2=r(mean)
			outreg2 using "$table_dir/EDCC_TableA12A.xls", excel label append depvar keep(sum_part sum_nonpart) nocons adds(P-value PAR: STD4=STD5, `H1', Mean of Dep. Var, `F2', BT_part, `G1' , BT_nonpart, `G2', Par STD4=STD5, `H1') addtext(Control, "Yes", Grade, "`q'")
			}
		
	
}
		

restore


	
******************************************************************************************
*** TABLE 3: The effect of summer school participation on follow-up survey test scores ***
******************************************************************************************

use "$cleaned_dir/language_master.dta", clear

gen newstd=99
replace newstd=4 if new_std==4
replace newstd=5 if new_std==5
replace newstd=6 if new_std==6
tab newstd, gen(haha)

gen int std4=1 if std==4
replace std4=2 if std==5 

gen t1=summer_part_chewa
gen t2=summer_part_eng
gen t3=summer_nonpart_chewa
gen t4=summer_nonpart_eng


est clear 

local yoyo "replace"
local toto "replace"

		
global ycon1 haha1 haha2 haha3
global ycon2 female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents haha1 haha2 haha3


* MHT-robust SEs
forval b=1/2 {

local e: word `b' of `" $ycon1" " $ycon1" " $ycon1" " $ycon1"' `" $ycon2" " $ycon2" " $ycon2" " $ycon2"' 
local g: word `b' of `"t1 t2 t3 t4"' `"t1 t2 t3 t4"'

display "`d'"
display "`e'"
wyoung fs_svysocialz fs_ssz fs_svymathz fs_mathz , cmd(areg OUTCOMEVAR "`g'" CONTROLVARS, r a(zone)) familyp("`g'") controls("`e'") bootstraps(10000) seed(98243532) cluster(school_code)
	
matrix table`b'=r(table)

scalar svysocialz_par_che`b' = table`b'[1,4]  
scalar ssz_par_che`b' = table`b'[2,4]  
scalar svymathz_par_che`b' = table`b'[3,4]  
scalar mathz_par_che`b' = table`b'[4,4]  

display "social_fs_par_che`b': " svysocialz_par_che`b'
display "social_t1_par_che`b': " ssz_par_che`b'
display "math_fs_par_che`b': " svymathz_par_che`b'
display "math_t1_par_che`b': " mathz_par_che`b'

scalar svysocialz_par_eng`b' = table`b'[5,4]  
scalar ssz_par_eng`b' = table`b'[6,4]  
scalar svymathz_par_eng`b' = table`b'[7,4]  
scalar mathz_par_eng`b' = table`b'[8,4]  

display "social_fs_par_eng`b': " svysocialz_par_eng`b'
display "social_t1_par_eng`b': " ssz_par_eng`b'
display "math_fs_par_eng`b': " svymathz_par_eng`b'
display "math_t1_par_eng`b': " mathz_par_eng`b'

scalar svysocialz_non_che`b' = table`b'[9,4]  
scalar ssz_non_che`b' = table`b'[10,4]  
scalar svymathz_non_che`b' = table`b'[11,4]  
scalar mathz_non_che`b' = table`b'[12,4]  

display "social_fs_non_che`b': " svysocialz_non_che`b'
display "social_t1_non_che`b': " ssz_non_che`b'
display "math_fs_non_che`b': " svymathz_non_che`b'
display "math_t1_non_che`b': " mathz_non_che`b'

scalar svysocialz_non_eng`b' = table`b'[13,4]  
scalar ssz_non_eng`b' = table`b'[14,4]  
scalar svymathz_non_eng`b' = table`b'[15,4]  
scalar mathz_non_eng`b' = table`b'[16,4]  

display "social_fs_non_eng`b': " svysocialz_non_eng`b'
display "social_t1_non_eng`b': " ssz_non_eng`b'
display "math_fs_non_eng`b': " svymathz_non_eng`b'
display "math_t1_non_eng`b': " mathz_non_eng`b'


}


forval i=1/4 {

local j: word `i' of "svysocialz" "ssz" "svymathz" "mathz"   


  forval k=1/2 {
  local l: word `k' of " " "$con" 
  local q: word `k' of "No" "Yes" 

	
	areg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng `l' i.newstd, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	local F2=r(p)
	test summer_part_eng=summer_nonpart_eng
	local F3=r(p)
	test summer_nonpart_chewa=summer_nonpart_eng
	local F4=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table3.xls", excel `yoyo' depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: C=E, `F1', P-value: C=C-non, `F2', P-value: E=E-non, `F3', P-value: C-non=E-non, `F4', BS P-value: C=E, `H1', Mean of Dep. Var, `F5', WCSE_summer_Chewa, `G1' , WCSE_summer_Eng, `G2', WCSE_nosummer_Chewa, `G3', WCSE_nosummer_Eng, `G4', MHT PAR_CHE p-val:, `j'_par_che`k', MHT PAR_ENG p-val:, `j'_par_eng`k', MHT NON_CHE p-val:, `j'_non_che`k', MHT NON_ENG p-val:, `j'_non_eng`k')	
	local yoyo "append"
  }
  
  

*** Heterogeneity analysis 
******************************************************************************************
*** TABLE A12 Panel B: Short-term Learning Camp Impacts by Grade
******************************************************************************************
  
  
* Heterogeneity analysis 
 
 	* mean difference test by grade
	qui reg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3  i.zone if std4==1
	est store r_`j'4
	qui reg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3 i.zone if std4==2
	est store r_`j'5

	qui suest r_`j'4 r_`j'5, cluster(school_code)
	test [r_`j'4_mean]summer_part_chewa = [r_`j'5_mean]summer_part_chewa
	local H1=r(p)
	test [r_`j'4_mean]summer_part_eng = [r_`j'5_mean]summer_part_eng
	local H2=r(p)

	est clear		

  
	forval k=1/2 {
		local q: word `k' of "STD4" "STD5"
	
		areg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con if std4==`k', absorb(zone) r cluster(school_code)
		boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p_1)
		local G2=r(p_2)
		local G3=r(p_3)
		local G4=r(p_4)
		summarize fs_`j' if lang3==0 & e(sample)==1
		local F5=r(mean)
		test summer_part_chewa=summer_part_eng
		local F1=r(p)
		outreg2 using "$table_dir/EDCC_TableA12B.xls", excel `toto' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', Mean of Dep. Var, `F5', WCSE_summer_Chewa, `G1' , WCSE_summer_Eng, `G2', WCSE_nosummer_Chewa, `G3', WCSE_nosummer_Eng, `G4', PAR_CHE STD4=STD5, `H1', PAR_ENG STD4=STD5, `H2') addtext(Control, "Yes", Grade, "`q'" )
		local toto "append"

		est clear
			}
		
}


*************************************************************************
* Table 3 Pooled, Standardized Scores (FS and Term 1 Finals)
*************************************************************************
preserve

* Term 1 exam
use "$cleaned_dir/language_master.dta", clear

keep id fs_ssz fs_mathz summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng bs_mathz bs_ssbkz school_code zone std female bs_chewa bs_ever_repeat bs_num_txtbk bs_bothparents std5 new_std lang3 bs_comz bs_cogz fs_cogz fs_comz fs_svymathz fs_svysocialz fs_ssz fs_mathz fs_totalz $hetero chichewa_good eng_good bs_listen_chiz bs_listen_engz bs_goodhealth bs_edumotive_score_z bs_subjectexp_af_z bs_subjectexp_gl_z bs_absent bs_studywkdays bs_misshw_dum bs_classenviron4_dum bs_classenviron5_dum bs_teacherpercep_score_z bs_parent_b_dum bs_parent_b_dum bs_parent_d_dum bs_parent_el_score_z bs_ownstationarya bs_ownstationaryb bs_ownstationaryc bs_subjectperfa_dum bs_subjectperfb_dum bs_subjectperfc_dum bs_subjectperfd_dum bs_subjectperfe_dum bs_subjectperff_dum

ren fs_ssz ssz
ren fs_mathz mathz
* Term 1 exam
gen type=1

append using "$cleaned_dir/T2POOL.dta"

gen newstd=99
replace newstd=4 if new_std==4
replace newstd=5 if new_std==5
replace newstd=6 if new_std==6

tab newstd, gen(haha)

gen int std4=1 if std==4
replace std4=2 if std==5 

gen school_code2=school_code+type*(100+school_code)

*** Preparation for RWOLF

gen t1=summer_part_chewa
gen t2=summer_part_eng
gen t3=summer_nonpart_chewa
gen t4=summer_nonpart_eng

* MHT-robust SEs

local toto "replace"
forval b=1/2 {

local e: word `b' of `" $ycon1" " $ycon1"' `" $ycon2" " $ycon2"' 
local g: word `b' of `"t1 t2 t3 t4"' `"t1 t2 t3 t4"'

wyoung ssz mathz, cmd(areg OUTCOMEVAR "`g'" CONTROLVARS, r a(zone)) familyp("`g'") controls("`e'") bootstraps(10000) seed(98243532) cluster(school_code)

matrix pable`b'=r(table)


scalar ssz_par_che`b' = pable`b'[1,4]  
scalar mathz_par_che`b' = pable`b'[2,4]  

display "social_t1_par_che`b': " ssz_par_che`b'
display "math_t1_par_che`b': " mathz_par_che`b'

scalar ssz_par_eng`b' = pable`b'[3,4]  
scalar mathz_par_eng`b' = pable`b'[4,4]  

display "social_t1_par_eng`b': " ssz_par_eng`b'
display "math_t1_par_eng`b': " mathz_par_eng`b'

scalar ssz_non_che`b' = pable`b'[5,4]  
scalar mathz_non_che`b' = pable`b'[6,4]  

display "social_t1_non_che`b': " ssz_non_che`b'
display "math_t1_non_che`b': " mathz_non_che`b'

scalar ssz_non_eng`b' = pable`b'[7,4]  
scalar mathz_non_eng`b' = pable`b'[8,4]  

display "social_t1_non_eng`b': " ssz_non_eng`b'
display "math_t1_non_eng`b': " mathz_non_eng`b'

}

forval i=1/2 {

local j: word `i' of "ssz" "mathz" 

  forval k=1/2 {
  local l: word `k' of " " "$con"
  
	areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng `l' i.newstd  type, absorb(zone) r cluster(school_code2)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code2) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize `j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	local F2=r(p)
	test summer_part_eng=summer_nonpart_eng
	local F3=r(p)
	test summer_nonpart_chewa=summer_nonpart_eng
	local F4=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table3.xls", excel append label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: C=E, `F1', P-value: C=C-non, `F2', P-value: E=E-non, `F3', P-value: C-non=E-non, `F4', BS P-value: C=E, `H1', Mean of Dep. Var, `F5', WCSE_summer_Chewa, `G1' , WCSE_summer_Eng, `G2', WCSE_nosummer_Chewa, `G3', WCSE_nosummer_Eng, `G4',  MHT PAR_CHE p-val:, `j'_par_che`k', MHT PAR_ENG p-val:, `j'_par_eng`k', MHT NON_CHE p-val:, `j'_non_che`k', MHT NON_ENG p-val:, `j'_non_eng`k')	
			
	}
			
			
* Heterogeneity analysis 
 
 	* mean difference test by grade
	qui reg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3 i.zone type if std4==1
	est store r_`j'f
	qui reg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3 i.zone type if std4==2
	est store r_`j'm

	qui suest r_`j'f r_`j'm, cluster(school_code)
	test [r_`j'f_mean]summer_part_chewa = [r_`j'm_mean]summer_part_chewa	
	local Z1=r(p)
	test [r_`j'f_mean]summer_part_eng = [r_`j'm_mean]summer_part_eng
	local Z2=r(p)

	est clear		

  
	forval k=1/2 {
		local q: word `k' of "STD4" "STD5"
	
		areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con type if std4==`k', absorb(zone) r cluster(school_code)
		boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p_1)
		local G2=r(p_2)
		local G3=r(p_3)
		local G4=r(p_4)
		summarize `j' if lang3==0 & e(sample)==1
		local F5=r(mean)
		test summer_part_chewa=summer_part_eng
		local F1=r(p)
		outreg2 using "$table_dir/EDCC_TableA12B.xls", excel append label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: C=E, `F1', Mean of Dep. Var, `F5', WCSE_summer_Chewa, `G1' , WCSE_summer_Eng, `G2', WCSE_nosummer_Chewa, `G3', WCSE_nosummer_Eng, `G4', PAR_CHE STD4=STD5, `Z1', PAR_ENG STD4=STD5, `Z2') addtext(Control, "Yes", Grade, "`q'" )

		est clear
			}
			
}

restore


******************************************************************************************
*** TABLES 4 and 5, Figure 2 Panels C and D: The effect of summer school participation on Term 2 Final Exam scores ***
******************************************************************************************

gen w1=sum_part
gen w2=sum_nonpart

gen t2_social = t2e_social_total_calcz
gen t2_socialsum = t2e_social_total_summerz
gen t2_socialnosum = t2e_social_total_nosummerz

gen t2_math = t2e_math_total_calcz
gen t2_mathsum = t2e_math_total_summerz
gen t2_mathnosum = t2e_math_total_nosummerz

gen t2_chi =  t2e_mark_chiz
gen t2_eng =  t2e_mark_engz
gen t2_art =  t2e_mark_artz
gen t2_sci =  t2e_mark_sciz
gen t2_total = t2e_mark_totalz 

label variable t2_chi "Term 2 Chichewa"
label variable t2_eng "Term 2 English"
label variable t2_art "Term 2 Art & Life Skills"
label variable t2_sci "Term 2 Science"
label variable t2_total "Term 2 Total"

*replace t2_total =. if t2_social==. | t2_math==. | t2_math==. | t2_chi==. | t2_eng==. | t2_art==. | t2_sci==. 

******************************************************************************************
** Figure 2 Panels C and D
******************************************************************************************
forval i=1/4 {

	local j: word `i' of  "t2_socialsum" "t2_socialnosum" "t2_mathsum" "t2_mathnosum" 
	local k: word `i' of "Social Studies Scores (Covered)" "Social Studies Scores (Not Covered)" "Mathematics Scores (Covered)"  "Mathematics Scores (Not Covered)" 
	local l: word `i' of  "C_Social_Covered" "D_Social_NotCovered" "C_Math_Covered" "D_Math_NotCovered"

	twoway (kdensity `j' if summer_part_chewa==1, bw(0.5) clcolor(black) clpattern(solid)) ///
	(kdensity `j' if summer_part_eng==1, bw(0.5)  clcolor(black) clpattern(shortdash)) /// 
	(kdensity `j' if lang3==0, bw(0.5)  clcolor(black) clpattern(dash) clwidth(vvthink)), ///
	title("AY17 Term 2 `k' ", margin(medsmall)) ytitle("") ///
	xtitle("", margin(small)) legend(order(1 "Chichewa Participants" 2 "English Participants" 3 "Control") position(6) rows(1)) xlabel(#9) xmtick(##2) ///
	graphregion(fcolor(white)) plotregion(fcolor(white))
	graph save Graph "$figure_dir/EDCC_Fig2_Panel_`l'.gph", replace
	graph export "$figure_dir/EDCC_Fig2_Panel_`l'.tif", replace width(2000)

}


******************************************************************************************
*** TABLES 4 and 5
******************************************************************************************

* Attrition variable for Term 2 exams
gen t2e_attrition=t2e_merge!=3
replace t2e_attrition=1 if t2e_mark_socialz==.
label variable t2e_attrition "Term 2 final exam attrition"



* MHT-robust SEs for Table 4
wyoung t2_socialsum t2_socialnosum t2_mathsum t2_mathnosum , cmd(areg OUTCOMEVAR "w1 w2" CONTROLVARS, r a(zone)) familyp("w1 w2") controls(" $ycon2" " $ycon2" " $ycon2" " $ycon2") bootstraps(10000) seed(98243532) cluster(school_code)
matrix table4=r(table)
scalar ss_cov_par4 = table4[1,4]  
scalar ss_nocov_par4 = table4[2,4]  
scalar math_cov_par4 = table4[3,4]  
scalar math_nocov_par4 = table4[4,4]  

display "Social Studies Covered PAR: " ss_cov_par4
display "Social Studies Not Covered PAR: " ss_nocov_par4
display "Math Covered PAR: " math_cov_par4
display "Math Not Covered PAR: " math_nocov_par4

scalar ss_cov_non4 = table4[5,4]  
scalar ss_nocov_non4 = table4[6,4]  
scalar math_cov_non4 = table4[7,4]  
scalar math_nocov_non4 = table4[8,4]  

display "Social Studies Covered NON: " ss_cov_non4
display "Social Studies Not Covered NON: " ss_nocov_non4
display "Math Covered NON: " math_cov_non4
display "Math Not Covered NON: " math_nocov_non4

* MHT-robust SEs for Table 5
wyoung t2_socialsum t2_socialnosum t2_mathsum t2_mathnosum , cmd(areg OUTCOMEVAR "t1 t2 t3 t4" CONTROLVARS, r a(zone)) familyp("t1 t2 t3 t4") controls(" $ycon2" " $ycon2" " $ycon2" " $ycon2") bootstraps(10000) seed(98243532) cluster(school_code)
matrix table5=r(table)

scalar ss_cov_par_che5 = table5[1,4]  
scalar ss_nocov_par_che5 = table5[2,4]  
scalar math_cov_par_che5 = table5[3,4]  
scalar math_nocov_par_che5 = table5[4,4]  

display "Social Studies Covered CHI_PAR: " ss_cov_par_che5
display "Social Studies Not Covered CHI_PAR: " ss_nocov_par_che5
display "Math Covered CHI_PAR: " math_cov_par_che5
display "Math Not Covered CHI_PAR: " math_nocov_par_che5

scalar ss_cov_par_eng5 = table5[5,4]  
scalar ss_nocov_par_eng5 = table5[6,4]  
scalar math_cov_par_eng5 = table5[7,4]  
scalar math_nocov_par_eng5 = table5[8,4]  

scalar ss_cov_non_che5 = table5[9,4]  
scalar ss_nocov_non_che5 = table5[10,4]  
scalar math_cov_non_che5 = table5[11,4]  
scalar math_nocov_non_che5 = table5[12,4]  

scalar ss_cov_non_eng5 = table5[13,4]  
scalar ss_nocov_non_eng5 = table5[14,4]  
scalar math_cov_non_eng5 = table5[15,4]  
scalar math_nocov_non_eng5 = table5[16,4]  


local yoyo "replace"

forval i=1/4 {

local j: word `i' of "t2_socialsum" "t2_socialnosum" "t2_mathsum" "t2_mathnosum" 
local k: word `i' of "ss_cov" "ss_nocov" "math_cov" "math_nocov" 
  
	areg `j'  sum_part sum_nonpart i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	
     // Output Table 4 
    outreg2 using "$table_dir/EDCC_Table4.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1', WCSE_NON, `G2', MHT PAR p-val:, `k'_par4, MHT NON p-val:, `k'_non4)
    
	areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize `j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	

    
    // Output Table 5 with Lee bounds
    outreg2 using "$table_dir/EDCC_Table5.xls", excel `yoyo' label depvar ///
        keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons ///
        adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', ///
             WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4', ///
             MHT PAR_CHE p-val:, `k'_par_che5, MHT PAR_ENG p-val:, `k'_par_eng5, ///
             MHT NON_CHE p-val:, `k'_non_che5, MHT NON_ENG p-val:, `k'_non_eng5)
    	
	local yoyo "append"
				
}


local yoyo "replace"

forval i=1/4 {

local j: word `i' of "t2_socialsum" "t2_socialnosum" "t2_mathsum" "t2_mathnosum" 
local k: word `i' of "ss_cov" "ss_nocov" "math_cov" "math_nocov" 
  
	areg `j'  sum_part sum_nonpart i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	
	// Lee bounds for sum_part vs control (Table 4)
    preserve
    keep if sum_part==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = sum_part
    gen selected = (t2e_attrition==0)  // 1 if not attrited
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_par = e(cilower)
    local lee_upper_par = e(ciupper)		
    restore
    
    // Lee bounds for sum_nonpart vs control (Table 4)
    preserve
    keep if sum_nonpart==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = sum_nonpart
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected)  vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_nonpar = e(cilower)
    local lee_upper_nonpar = e(ciupper)
    restore
     // Output Table 4 with Lee bounds
    outreg2 using "$table_dir/EDCC_Table4_LeeBound.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1', WCSE_NON, `G2', MHT PAR p-val:, `k'_par4, MHT NON p-val:, `k'_non4, Lee Lower PAR, `lee_lower_par', Lee Upper PAR, `lee_upper_par', Lee Lower NON, `lee_lower_nonpar', Lee Upper NON, `lee_upper_nonpar')
    
    
	
	areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize `j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	

	// Lee bounds for summer_part_chewa vs control (Table 5)
    preserve
    keep if summer_part_chewa==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = summer_part_chewa
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_par_che = e(cilower)
    local lee_upper_par_che = e(ciupper)
    restore
    
    // Lee bounds for summer_part_eng vs control (Table 5)
    preserve
    keep if summer_part_eng==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = summer_part_eng
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_par_eng = e(cilower)
    local lee_upper_par_eng = e(ciupper)
    restore
    
    // Lee bounds for summer_nonpart_chewa vs control (Table 5)
    preserve
    keep if summer_nonpart_chewa==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = summer_nonpart_chewa
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_non_che = e(cilower)
    local lee_upper_non_che = e(ciupper)
    restore
    
    // Lee bounds for summer_nonpart_eng vs control (Table 5)
    preserve
    keep if summer_nonpart_eng==1 | (sum_part==0 & sum_nonpart==0)
    gen treated = summer_nonpart_eng
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_non_eng = e(cilower)
    local lee_upper_non_eng = e(ciupper)
    restore
    
    // Optional: Lee bounds for language comparison within participation group
    // summer_part_chewa vs summer_part_eng
    preserve
    keep if summer_part_chewa==1 | summer_part_eng==1
    gen treated = summer_part_eng  // English as "treatment", Chewa as "control"
    gen selected = (t2e_attrition==0)
    leebounds `j' treated, select(selected) vce(boot, reps(10000) nodots) cieffect level(95)
    local lee_lower_lang_comp = e(cilower)
    local lee_upper_lang_comp = e(ciupper)
    restore
    
    // Output Table 5 with Lee bounds
    outreg2 using "$table_dir/EDCC_Table5_LeeBound.xls", excel `yoyo' label depvar ///
        keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons ///
        adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', ///
             WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4', ///
             MHT PAR_CHE p-val:, `k'_par_che5, MHT PAR_ENG p-val:, `k'_par_eng5, ///
             MHT NON_CHE p-val:, `k'_non_che5, MHT NON_ENG p-val:, `k'_non_eng5, ///
             Lee Lower PAR_CHE, `lee_lower_par_che', Lee Upper PAR_CHE, `lee_upper_par_che', ///
             Lee Lower PAR_ENG, `lee_lower_par_eng', Lee Upper PAR_ENG, `lee_upper_par_eng', ///
             Lee Lower NON_CHE, `lee_lower_non_che', Lee Upper NON_CHE, `lee_upper_non_che', ///
             Lee Lower NON_ENG, `lee_lower_non_eng', Lee Upper NON_ENG, `lee_upper_non_eng', ///
             Lee Lower LANG_COMP, `lee_lower_lang_comp', Lee Upper LANG_COMP, `lee_upper_lang_comp')
    
	
	local yoyo "append"
				
}


******************************************************************************************
*** TABLE A13 Longer-term Outcomes by Grade 
******************************************************************************************


local momo "replace"
forval i=1/4 {

	local j: word `i' of "t2_socialsum" "t2_socialnosum" "t2_mathsum" "t2_mathnosum" 
	

	* Mean difference test between STD4 and STD5
	qui reg `j'  sum_part sum_nonpart $con haha1-haha3  i.zone if std4==1
	est store r_`j'f
	qui reg `j'  sum_part sum_nonpart $con haha1-haha3  i.zone if std4==2
	est store r_`j'm

	qui suest r_`j'f r_`j'm, cluster(school_code)
	test [r_`j'f_mean]sum_part = [r_`j'm_mean]sum_part
	local H1=r(p)
	
	qui reg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3 i.zone  if std4==1
	est store r_`j'f
	qui reg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con haha1-haha3  i.zone  if std4==2
	est store r_`j'm

	suest r_`j'f r_`j'm, cluster(school_code)
	test [r_`j'f_mean]summer_part_chewa = [r_`j'm_mean]summer_part_chewa	
	local H2=r(p)
	est clear
	
	
	
		forval k=1/2 {
		local q: word `k' of "STD4" "STD5"
  
		areg `j'  sum_part sum_nonpart i.newstd $con if std4==`k', absorb(zone) r cluster(school_code)
		boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p_1)
		local G2=r(p_2)
		summarize `j' if lang3==0 & e(sample)==1
		local F5=r(mean)
		test sum_part=sum_nonpart
		local F1=r(p)
		boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
		local F2=r(p)
		outreg2 using "$table_dir/EDCC_TableA13A.xls", excel `momo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `F2', Mean of Dep. Var, `F5', WCSE_PAR, `G1' , WCSE_NON, `G2', SUM_PAR STD4=STD5, `H1') addtext(Grade, "`q'")	
		

		areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con if std4==`k', absorb(zone) r cluster(school_code)
		boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
		local G1=r(p_1)
		local G2=r(p_2)
		local G3=r(p_3)
		local G4=r(p_4)
		summarize `j' if lang3==0 & e(sample)==1
		local F5=r(mean)
		test summer_part_chewa=summer_part_eng
		local F1=r(p)
		boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
		local F2=r(p)
		outreg2 using "$table_dir/EDCC_TableA13B.xls", excel `momo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `F2', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1' , WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4', CHI_PAR STD4=STD5, `H2') addtext(Grade, "`q'")		
		
		local momo "append"
		}
					
}



******************************************************************************************
*** TABLE A10 Longer-term Outcomes on Non-learning camp subjects
******************************************************************************************

local yoyo "replace"

forval i=1/5 {

local j: word `i' of "t2_chi" "t2_eng" "t2_art" "t2_sci" "t2_total"

  
  	areg `j'  sum_part sum_nonpart i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A10A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')	
	
	
	areg `j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd $con, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize `j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table_A10B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')	
	local yoyo "append"
}
	


******************************************************************************************
*** TABLE A5
******************************************************************************************


label variable fs_comz "Arithmetic"
label variable fs_cogz "Cognitive"


local yoyo "replace"
forval i=1/2 {

local j: word `i' of "comz" "cogz" 

  forval k=1/2 {
	  local l: word `k' of " " "$con"
	  local q: word `k' of "No" "Yes"
  
  
  	areg fs_`j' sum_part sum_nonpart i.newstd `l' , absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table_A5A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')	addtext(Control:, `q')
	

	areg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd `l', absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table_A5B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4') addtext(Control:, `q')
	local yoyo "append"
	
		}
}		

	
******************************************************************************************
*** TABLE A6
******************************************************************************************
label variable fs_chiz "Chichewa (Term 1 final)"
label variable fs_engz "English (Term 1 final)"
label variable fs_sciz "Science (Term 1 final)"
label variable fs_art_lifez "Art & Life Skills (Term 1 final)"
label variable fs_totalz "Total (Term 1 final)"
	
local yoyo "replace"

forval i=1/5 {

local j: word `i' of "chiz" "engz" "sciz" "art_lifez" "totalz" 

  forval k=1/2 {
	local l: word `k' of " " "$con"
    local q: word `k' of "No" "Yes"
  
  	areg fs_`j' sum_part sum_nonpart i.newstd `l' , absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table_A6A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')	addtext(Control:, `q')
	

	areg fs_`j' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng i.newstd `l', absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	summarize fs_`j' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)	
	outreg2 using "$table_dir/EDCC_Table_A6B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')	addtext(Control:, `q')
	local yoyo "append"
	
		}
}		


	
******************************************************************************************
*** TABLE A7: The effect of summer school participation on student motivation (Term 1 and Term 2 follow-up surveys) ***
******************************************************************************************
label variable fs_edumotive_score_z "Education aspiration (Term 1 Follow-up survey)"
label variable fs_subjectexp_af_z "Like studying (Term 1 Follow-up survey)"
label variable fs_subjectexp_gl_z "Study hard (Term 1 Follow-up survey)"
label variable f2_like_study_total_z "Like studying (Term 2 Follow-up survey)"
label variable f2_study_hard_total_z "Study hard (Term 2 Follow-up survey)"

global t6  fs_edumotive_score_z fs_subjectexp_af_z fs_subjectexp_gl_z f2_like_study_total_z f2_study_hard_total_z 


* Follow-up survey add'l var regression: educ-related

est clear

local yoyo "replace"

foreach i of varlist $t6 {
  

  	areg `i'  sum_part sum_nonpart $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `i' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A7A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')
	
	areg `i' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	* mean of the control group
	summarize `i' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	test summer_part_chewa=summer_nonpart_chewa
	local F2=r(p)
	test summer_part_eng=summer_nonpart_eng
	local F3=r(p)
	test summer_nonpart_chewa=summer_nonpart_eng
	local F4=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A7B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')
	local yoyo "append"
}
	

	
******************************************************************************************
*** TABLE AT7: The effect of summer school participation on student motivation (Term 1 and Term 2 follow-up surveys) ***
******************************************************************************************
label variable fs_edumotive_score_z "Education aspiration (Term 1 Follow-up survey)"
label variable fs_subjectexp_af_z "Like studying (Term 1 Follow-up survey)"
label variable fs_subjectexp_gl_z "Study hard (Term 1 Follow-up survey)"
label variable f2_like_study_total_z "Like studying (Term 2 Follow-up survey)"
label variable f2_study_hard_total_z "Study hard (Term 2 Follow-up survey)"

global t6  fs_edumotive_score_z fs_subjectexp_af_z fs_subjectexp_gl_z f2_like_study_total_z f2_study_hard_total_z 


* Follow-up survey add'l var regression: educ-related

est clear

local yoyo "replace"

foreach i of varlist $t6 {
  

  	areg `i'  sum_part sum_nonpart $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `i' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A7A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')
		
	areg `i' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	* mean of the control group
	summarize `i' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A7B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')
	local yoyo "append"
}
	


******************************************************************************************
*** TABLE AT8: The effect of summer school participation on student efforts (Term 1 and Term 2 follow-up surveys) ***
******************************************************************************************

global at9  random_present fs_absent fs_studywkdays fs_misshw_dum fs_classenviron4_dum fs_classenviron5_dum


label variable random_present "Attendance (random visit)"
label variable fs_absent "Number of missing days (Term 1 Follow-up survey)"
label variable fs_studywkdays "Number of days studied outside school during weekdays (Term 1 Follow-up survey)"
label variable fs_misshw_dum "Never missed homework last month (Term 1 Follow-up survey)"
label variable fs_classenviron4_dum "Helped friends understand school work (Term 1 Follow-up survey)"
label variable fs_classenviron5_dum "Asked friends to help understand school work (Term 1 Follow-up survey)"


local yoyo "replace"

foreach i of varlist $at9 {

  	areg `i'  sum_part sum_nonpart $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `i' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A8A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')
	
	areg `i' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	* mean of the control group
	summarize `i' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A8B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')
	local yoyo "append"

}


******************************************************************************************
*** TABLE AT9: The effect of summer school participation on Teaching Effectivness and Parental Engagement (Term 1 and Term 2 follow-up surveys) ***
******************************************************************************************


gen fs_t8a = fs_teacherpercep_score_z	
gen fs_t8b = fs_studywkdays_companya
gen fs_t8c = fs_parent_b_dum
gen fs_t8d = fs_parent_d_dum
gen fs_t8e = fs_parent_el_score_z
gen fs_t8f = f2_study_parents_total_z

global at10 fs_t8a fs_t8b fs_t8c fs_t8d fs_t8e fs_t8f


label variable fs_t8a "Teaching effectiveness index"
label variable fs_t8b "Studies with parents outside school during weekdays (Term 1 Follow-up survey)"
label variable fs_t8c "Father encourages to study hard (Term 1 Follow-up survey)"
label variable fs_t8d "Mother encourages to study hard (Term 1 Follow-up survey)"
label variable fs_t8e "Parents' study engagement (Term 1 Follow-up survey)"
label variable fs_t8f "Parents' study engagement (Term 2 Follow-up survey)"

est clear

local yoyo "replace"

foreach i of varlist $at10 {

  	areg `i'  sum_part sum_nonpart $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {sum_part} {sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	summarize `i' if lang3==0 & e(sample)==1
	local F2=r(mean)
	test sum_part=sum_nonpart
	local F1=r(p)
	boottest {sum_part=sum_nonpart}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A9A.xls", excel `yoyo' label depvar keep(sum_part sum_nonpart) nocons adds(P-value: PAR=NON, `F1', BS P-value:, `H1', Mean of Dep. Var, `F2', WCSE_PAR, `G1' , WCSE_NON, `G2')
	
	
	
	areg `i' summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng $con i.newstd, absorb(zone) r cluster(school_code)
	boottest {summer_part_chewa} {summer_part_eng} {summer_nonpart_chewa} {summer_nonpart_eng}, reps(10000) cluster(school_code) nograph seed(98243532)
	local G1=r(p_1)
	local G2=r(p_2)
	local G3=r(p_3)
	local G4=r(p_4)
	* mean of the control group
	summarize `i' if lang3==0 & e(sample)==1
	local F5=r(mean)
	test summer_part_chewa=summer_part_eng
	local F1=r(p)	
	boottest {summer_part_chewa=summer_part_eng}, reps(10000) cluster(school_code) nograph seed(98243532)	
	local H1=r(p)
	outreg2 using "$table_dir/EDCC_Table_A9B.xls", excel `yoyo' label depvar keep(summer_part_chewa summer_part_eng summer_nonpart_chewa summer_nonpart_eng) nocons adds(P-value: CHI_PAR=ENG_PAR, `F1', BS P-value:, `H1', Mean of Dep. Var, `F5', WCSE_CHI_PAR, `G1', WCSE_ENG_PAR, `G2', WCSE_CHI_NON, `G3', WCSE_ENG_NON, `G4')
	
	local yoyo "append"

}

